package com.cn.Utils;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.io.Serializable;

/**
 * Created by chenyuncong on 2018/8/2.
 */
public class MyPageable implements Serializable,Pageable {
    private static final long serialVersionUID = 1L;

    private Integer pagenumber = 1;
    // 当前页面条数
    private Integer pagesize = 10;
    // 排序条件
    private Sort sort;

    public MyPageable() {
    }

    public MyPageable(Integer pagenumber, Integer pagesize) {
        this.pagenumber = pagenumber;
        this.pagesize = pagesize;
    }

    public MyPageable(Integer pagenumber, Integer pagesize, Sort sort) {
        this.pagenumber = pagenumber;
        this.pagesize = pagesize;
        this.sort = sort;
    }

    @Override
    public Pageable first() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getOffset() {
        // TODO Auto-generated method stub
        return (this.pagenumber - 1) * this.pagesize;
    }

    @Override
    public int getPageNumber() {
        // TODO Auto-generated method stub
        return this.pagenumber;
    }

    @Override
    public int getPageSize() {
        // TODO Auto-generated method stub
        return this.pagesize;
    }


    @Override
    public boolean hasPrevious() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public Pageable next() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Pageable previousOrFirst() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Sort getSort() {
        // TODO Auto-generated method stub
        return this.sort;
    }

    public void setSort(Sort sort) {
        this.sort = sort;
    }
}
